package com.xyhuo.leetcode;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateTest {


    public static void main(String[] args) {

        Calendar calendar = Calendar.getInstance();
        int currentMonth = calendar.get(Calendar.MONTH) + 1;
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (int i = 0; i < currentMonth; i++) {
            Calendar cld=Calendar.getInstance();
            cld.setTime(new Date());
            cld.set(Calendar.MONTH,i);
            cld.set(Calendar.DAY_OF_MONTH,1);
            cld.set(Calendar.HOUR,0);
            cld.set(Calendar.MINUTE,0);
            cld.set(Calendar.SECOND,0);
            Date monthFirstDay = cld.getTime();
            System.out.println(sdf.format(monthFirstDay));
            cld.set(Calendar.MONTH,i+1);
            cld.set(Calendar.DAY_OF_MONTH,0);
            cld.set(Calendar.HOUR,23);
            cld.set(Calendar.MINUTE,59);
            cld.set(Calendar.SECOND,59);
            Date lastMonthLastDay = cld.getTime();
            System.out.println(sdf.format(lastMonthLastDay));
            System.out.println();
        }


    }



//    public static void main(String[] args) {
//        BigDecimal currentYearDecimal = BigDecimal.valueOf(10);
//        BigDecimal lastYearDecimal = BigDecimal.valueOf(20);
//        BigDecimal difference = currentYearDecimal.subtract(lastYearDecimal);
//        BigDecimal ans = difference.divide(lastYearDecimal).setScale(2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
//        System.out.println(ans);
//    }
}
